<?php
	$path_one = 'admin/admin_project';
	$path_two = 'admin/admin_address_device_log';
	$filename = 'admin/admin_address_device_log';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
	require_once $_site->get_handlepath('device');

	$page=request('page',false,true,false,1);
	$pagesize=request('pagesize',false,true,false,20);
	$pagesize = is_numeric($pagesize)?$pagesize:20;



	$start_time=$data['start_time']=request('start_time');
	$end_time=$data['end_time']=request('end_time');
if(empty($start_time) && empty($end_time)){
    $now_time=strtotime(date("Y-m-d",time()));
    $start_time=$data['start_time']=date("Y-m-d H:i:s",$now_time);
    $end_time=$data['end_time']=date("Y-m-d H:i:s",$now_time+86399);
}

	$data['pid']=request('pid',false,true,false,0);

	$data['no']=request('no');
	$data['gascan']=request('gascan');
	$data['carno']=request('carno');
	$data['gaser']=request('gaser');
	$data['cartype']=$cartype=request('cartype');
	$data['state']=1;
	$no_title=request('no_title');
	$data['type']=1;

	$obj_gas=new gas();
	$result = $obj_gas->get_list($data,$page,$pagesize);


	function time2second($seconds){
		$seconds = (int)$seconds;
		if($seconds<3600){
			$format_time = gmstrftime('%M 分 %S 秒 ', $seconds);
		}elseif( $seconds<86400 ){//如果不到一天
			$format_time = gmstrftime('%H 时 %M 分 %S 秒 ', $seconds);
		}else{
			$time = explode(' ', gmstrftime('%j %H %M %S', $seconds));
			$format_time = ($time[0]-1).'天'.$time[1].'时'.$time[2].'分'.$time[3].'秒';
		}
		return $format_time;
	}
?>
<link rel="stylesheet" type="text/css" href="/static/skin/green/css/list.css">
<script type="text/javascript" charset="utf-8">

	loader.file({
		plugin:['validform/main','dialog/main','my97/wdatepicker']
	})
	function get_project_info (){
		dialog.iframe({
			title:'项目选择',
			is_resize:false,
			top:{
				is_show:true,
				btn_max:false,
				btn_min:false,
				btn_close:true,
				height:33,
				is_move:true
			},
			is_scroll:false,
			min_width:380,
			min_height:400,
			is_center:true,
			is_lock_back:true,
			content:'/admin/common_choise?callback=set_project_info&parm=state.1',
			name:'choise_project'
		});
	}

	function set_project_info(id,title){
		if(id && title){
			$("#pid").val(id);
			$("#name_title").val(title);
			get_address_list(id);
		}
	}


	function import_out(obj){
		var _this=$(obj);
		var request_url = _this.parents('form').serialize();
		window.location.href="/handle.php?h=gas/improt_out&"+request_url;
		return false;
	}


	function import_out_als(obj){
		var _this=$(obj);
		var request_url = _this.parents('form').serialize();
		window.location.href="/handle.php?h=gas/improt_out_report&"+request_url;
		return false;
	}


    //数据校验
    function data_verify(obj){
        var _this=$(obj);
        var request_url = _this.parents('form').serialize();
        window.location.href="/?v=/admin/device_gas_check&"+request_url;
        return false;
    }

	function nouse(id){
       if(!confirm('确认设置记录为无效 ？')){
            return false;
       }

       $.getJSON('/handle.php',{id:id,h:'gas/nouse'},function(res){
           if(res.state){
                 $("#no_"+id).remove();
                 return false;
           }
           alert(res.msg);
       });
	}


    //修改记录
	function editinfo(id){
		dialog.iframe({
			title:'修改登记记录',
			is_resize:false,
			top:{
				is_show:true,
				btn_max:false,
				btn_min:false,
				btn_close:true,
				height:33,
				is_move:true
			},
			is_scroll:false,
			min_width:820,
			min_height:550,
			is_center:true,
			is_lock_back:true,
			content:'/admin/editgas?id='+id,
			name:'choise_project'
		});
	}

	function change(info){
		location.reload(true);
	}
</script>
<style>
.goodimg{width:298px;background: #efefef none repeat scroll 0 0;border: 1px solid #aad381;}
.goodwarn{width:298px;background: #ff0 none repeat scroll 0 0;border: 1px solid #ff0000;}
.table li{float:left;margin-right: 10px;margin-top: 10px;text-align: center;}
.table img{max-width:58px;height:70px;margin:5px;}
.table .operation{background:#aad381}
.table_cell tr td {
    color: rgb(85, 85, 85);
    font-family: Verdana, Arial, Helvetica, sans-serif;
	padding: 5px;
	text-align:left;
}
.table_cell tr{height:24px;}
.table .operation{background:#aad381}
</style>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?></div>
		<div class="main">

			<div class="sos_box">
				<form action="/admin/gasout" id="search" method='get'>
					<input type="hidden" name="type" value="1">
					<span>选择项目：</span>
					<input type="hidden" name="pid" id='pid' value="<?php echo $data['pid'] ;?>">
					<input type="text" name='no_title' id='name_title' readonly="readonly" value="<?php echo $no_title ;?>" onclick='get_project_info();'>
					<span>手机设备号：</span>
					<input type="text"  name="no" value="<?php echo $data['no'] ;?>">
					<span>油罐号：</span>
					<input type="text"  name="gascan" value="<?php echo $data['gascan'] ;?>">
					<span>加油设备号：</span>
					<input type="text" style="width:100px" name="carno" value="<?php echo $data['carno'] ;?>">
					<span>车辆类型：</span>
					<input type="text" style="width:100px" name="cartype" value="<?php echo $data['cartype'] ;?>">
					<span>加油人员编号：</span>
					<input type="text" style="width:100px" name="gaser" value="<?php echo $data['gaser'] ;?>">
					<div style="clear: both;width:100%;*height:0px;margin:5px 0;"></div>
					<span>按登记时间段搜索：</span>
					<style type="text/css">
						#d4311,#d4312,#time_limit{background: url('http://www.my97.net/dp/My97DatePicker/skin/datePicker.gif') no-repeat right center;}
					</style>
					<input class='date_icon' type="text" id="d4311" name="start_time" value="<?php echo $start_time ;?>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'d4312\')||\'<?php echo date('Y-m-d');?>\'}',readOnly:true})"> -
					<input type="text" id="d4312" name="end_time" value="<?php echo $end_time ;?>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'d4311\')}',maxDate:'<?php echo date('Y-m-d');?>',readOnly:true})">
					单页记录：<input type="text" style="width: 40px" name="pagesize" value="<?php echo $pagesize?>">
					<input class="button1" type="submit" value="搜索">
					<?php if($cookie['group']!=12){?>
					<input class="button1" type="button" onclick="import_out(this);return false;" value="导出加油明细">
					<input class="button1" type="button" onclick="import_out_als(this);return false;" value="导出加油报表">
                        <input class="button1" type="button" onclick="data_verify(this);return false;" value="数据校验">
					<?php }?>
					<div style="clear: both;width:100%;*height:0px;margin:5px 0;"></div>
				</form>
			</div>
			<table cellpadding="0" cellspacing="1" border="0" class="table">
				<?php
					if($result['rows']){
                 ?>
                 <tr><td>
                 <?php
				   foreach ($result['rows'] as $k=>$v){
                       $_class=false?'goodwarn':'goodimg';
				 ?>
			     <li id="no_<?php echo $v['id'];?>">
                     <div class="<?php echo $_class;?>">
                         <table class="table_cell">
                            <tr style="display:none;">
                              <td>
                                <a href="<?php echo $v['img_start'];?>" title="点击查看大图" target="_blank">
	                              <img src='<?php $img=1==$v['img_start']?'/static/images/imgdel.jpg':$v['img_start'];echo $img ;?>' width="156px" height="80px">
						        </a>
                              </td>
                              <td>
						        <a href="<?php echo $v['img_end'];?>" title="点击查看大图" target="_blank">
	                              <img src='<?php $img=1==$v['img_end']?'/static/images/imgdel.jpg':$v['img_end'];echo $img ;?>' width="156px" height="80px">
						        </a>
                              </td>
                            </tr>

                             <tr>
                                 <td colspan="2">
                                     <a href="<?php echo $v['img_start'];?>" title="点击查看大图" target="_blank">
                                         <img src='<?php $img=1==$v['img_start']?'/static/images/imgdel.jpg':$v['img_start'];echo $img ;?>'>
                                     </a>
                                     <a href="<?php echo $v['img_end'];?>" title="点击查看大图" target="_blank">
                                         <img src='<?php $img=1==$v['img_end']?'/static/images/imgdel.jpg':$v['img_end'];echo $img ;?>'>
                                     </a>
                                     <?php if($v['img_three']){ ?>
                                     <a href="<?php echo $v['img_three'];?>" title="点击查看大图" target="_blank">
                                         <img src='<?php echo $v['img_three'] ;?>' >
                                     </a>
                                     <?php } ?>
                                     <?php if($v['img_four']){ ?>
                                     <a href="<?php echo $v['img_four'];?>" title="点击查看大图" target="_blank">
                                         <img src='<?php echo $v['img_four'] ;?>'>
                                     </a>
                                     <?php } ?>
                                 </td>
                             </tr>

                            <tr>
                              <td>加油前 : <strong><?php echo $v['num_start'] ?></strong></td>
                              <td>加油后 : <strong><?php echo $v['num_end'] ?></strong></td>
                            </tr>

                            <tr>
                              <td><?php echo date('Y-m-d H:i:s',$v['time_start']); ?></td>
                              <td><?php echo date('Y-m-d H:i:s',$v['time_end']);?></td>
                            </tr>

                            <tr>
                              <td>用时：<?php echo time2second($v['time_all']); ?></td>
                              <td>加油量：<?php echo abs($v['num_all']);?></td>
                            </tr>

                            <tr>
                              <td>油价：<?php echo $v['price']>0?$v['price']:'--'; ?></td>
                              <td>金额：<?php echo $v['sum']>0?$v['sum']:'--';?></td>
                            </tr>

                            <tr>
                              <td>员工编号：<?php echo $v['gaser']; ?></td>
                              <td>油罐编号：<?php echo $v['gascan'];?></td>
                            </tr>

                            <tr>
                              <td>加油设备：<?php echo $v['carno']; ?></td>
                              <td>车辆类型：<?php echo $v['cartype']; ?></td>
                            </tr>

                            <tr>
                              <td colspan="2">设备编号：<?php echo $v['no']; ?></td>
                            </tr>

                         </table>

                         <p class="operation">
		                     <?php if($cookie['group']!=12){?>
		                       <a href="javascript:;" onclick="editinfo(<?php echo $v['id'];?>);" >编辑</a>
		                       &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="nouse(<?php echo $v['id'];?>);" title="点击设置记录无效">无效</a>
		                     <?php } ?>
                         </p>
                     </div>
                 </li>
				<?php
					}
				?>
						</td></tr>
						<?php
					}else{
						?>
						<tr>
							<td colspan="10">暂无数据！</td>
						</tr>
						<?php
					}
				?>
				<tr>
					<td colspan="10">
						<div class="list_more">
							记录总数：<?php echo $result['row_count']?$result['row_count']:0 ;?>
							<?php
								echo page_method($result['row_count'], $page, $result['page_count'], 10, '?'.preg_replace('/(&page=\d*)/','',$_SERVER['QUERY_STRING']), false);
							?>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</div>
</body>
</html>


